Part Number Hot Search : 
024810 AT89C F00017 AK4220VQ 5KP90A W682310 A82C25 RT9267GC
Product Description
Full Text Search
 

To Download AP1627 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 Microcontrollers ApNote
AP162701.EXE available
AP1627
additional file
Software module of M3L-bus by using HS-SSC for C16x microcontroller family.
This is a software module of M3L-bus by using High-Speed Synchronous Serial Channel for C16X microcontroller family. The M3L-bus is used mainly to communicate between the microcontroller and Television application IC like MegaText, and Compact Text.
Author: Tan Choon Hock/SCPL HL RM LAB
Semiconductor Group
1.97, Rel. 01
Software module of M3L-bus by using HS-SSC for C16X uC family
1 Introduction to M3L-bus .............................................................................................. 3 2 M3L-bus Specifications ............................................................................................... 3 2.1 Data Transfer Formats ................................................................................................. 3 2.2 Timing Diagram ............................................................................................................ 5 2.3 Hardware Connection................................................................................................... 7
3 Description of Software ................................................................................................ 8 3.1 Software Concept......................................................................................................... 8 3.2 Description of Module Subroutines .............................................................................. 9 3.3 Compilation of Software ............................................................................................. 13
AP1627 ApNote - Revision History Actual Revision : Rel. 01 Previous Revision: none (Original Version) Page of Page of actual Rel. prev. Rel.
Semiconductor Group
2 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
1
Introduction to M3L-bus
The M3L-bus is a single master protocol which consists of 3-wire bus; the SCL(clock), SDA(data), and I2CEN (for START and STOP condition). The clock frequency can achieve up to 1.0 MHz that means faster data transfer rate as the I2C Bus. The microcontrollers from Siemens have a hardware interface which can be used for M3L-bus protocol. This software module is using the hardware peripheral of High-Speed Synchronous Serial Channel for the C16X microcontroller family.
2 2.1
M3L-bus Specification Data Transfer formats
When there is a HIGH to LOW transition on the I2CEN line, it indicates a START condition. A LOW to HIGH transition on the I2CEN is defined as the STOP condition. The data line can only be changed when the clock signal on the SCL line is HIGH. Therefore, the data on the SDA line must be stable during the LOW period of the clock signal. Each information puts on the SDA line must be 8-bit long. There is no acknowledge bit followed by every byte sent for this M3L-bus protocol. The reason for not implement the acknowledge bit is that the MegaText IC comes with input filter in the SDA and SCL lines which will suppress high-frequency interference on those lines. In M3L-bus mode, the LSB of the data is transmitted first. For example, if the chip selected address is MSB R/W 1000100 LSB, then the data on the SDA line will be LSB 0010001(R/W) MSB. The difference from I2C is that the READ/WRITE bit is on the MSB position. The write select address will be 44H, and read select address in this case is C4H. If the transmitted or received data is MSB 10110001 LSB, the data on the SDA line will be LSB 10001101 MSB. The USART peripheral of the Siemens' microcontroller will be sending and receiving the LSB bit first. The data of transmit and receive shift registers are in the normal format MSB xxxxxxxx LSB. Therefore, there is no additional software involved for any conversion of data. There are only two basic types of data transfer format for M3L-bus. Figure #1 shows the M3L -bus data transfer format of writing data from microcontroller/master to MegaText/slave. Figure #2 shows the data transfer format of reading data from the MegaText/slave to microcontroller/master.
Semiconductor Group
3 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
I2CEN
SCL 1-7 SDA 8 1-7 8 1-7 8
Start Condition Slave Address Write Sub address Data Data
Stop Condition
Start Slave Address
Write
Sub address
Data
Data
Stop
Figure 1: M3L-bus data transfer format of writing data to slave
I2CEN
SCL 1-7 SDA Start Condition Slave Address Write Sub address Stop Start Slave Read Address Data Data 8 1-7 8 1-7 8 1-7 8
Stop Condition
Start Slave Address
Write
Sub Addr
Stop Start
Sub Addr
Read
Data
Data
Stop
Figure 2: M3L-bus data transfer format of reading data from slave
Semiconductor Group
4 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
2.2
Timing Diagram
The clock frequency of SCL is in the range of 0 up to 1.0MHz. The clock on the M3L-bus has a minimum LOW and HIGH period of 400ns. Occasionally, the MegaText/slave device may slow down the transmission by holding the clock line low after receiving a byte of data from microcontroller. This phenomenon is defined as a WAIT condition. Therefore, microcontroller/master needs to switch the SCL output to high impedance and read the SCL line before transmitting another byte of data to the slave device. Figure #3 shows the data transfer timing requirements in detail. The description of the abbreviations used is shown in the Table #1. The minimum timing requirements are needed to be fulfilled in order for M3L-bus to operate properly.
I2CEN
t IS
SCL
tHIGH tLOW
tIM
tDSL
SDA
tDSL tDHH t DO
tDWAIT
SCL WAIT
t RWAIT W ait Condition
Figure 3: M3L-bus timing diagram
Semiconductor Group
5 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
Table 1: Abbreviation for M3L-bus timing diagram Parameter Symbol Limit Values min. 1. Set-up time I2CEN to SDA falling edge 2. Set-up time SDA input to SCL falling edge 3. Hold time for SDA input from SCL falling edge to the next rising edge of SCL 4. HIGH-time clock 5. LOW-time clock 6. Delay from SCL rising edge until SDA open drain output stage changes impedance 7. Set-up time from SDA to I2CEN rising edge 8. Delay from SCL rising edge to SCL forced low for WAIT condition 9. SCL pull-up time at the end of WAIT condition 10. SCL load capacitance 11. SDA low level output impedance tIS tDSL tDHH 400 100 400 typ. max. ns ns ns Unit
tHIGH tLOW tDO
400 400 250 500
ns ns ns
tIM tDWAIT
400 500 750
ns ns
tRWAIT CSCL
70
100 200 100
ns pF
Semiconductor Group
6 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
2.3
Hardware Connection
Every device connected to the M3L-bus must have an open drain/open collector output for both the clock (SCL) and data (SDA) lines. Each of the lines is connected to the VDD supply via a common pull-up resistor of 3.9 K in value. The I2CEN line can be configured as a push-pull output. The connection among master and many slave's devices is shown in figure #4. The number of devices can be connected to the M3L-bus is limited only by the maximum bus load capacitance of 200pF.
V DD 3 .9 K P 3 .7 (S C L K ) P 3 .1 3 (M T S R ) P 3 .9 (M R S T ) P 3 .8 3 .9 K I2 C E N SC L SD A
M egaT ext
C 16X uC
I2 C E N SC L SD A
S la v e
Figure 4: Hardware connection among master and slave devices
Semiconductor Group
7 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
3 3.1
Description of Software Software Concept
The M3L-bus is generated by the High-Speed Synchronous Serial Channel of the C16X microcontroller. The clock frequency of the M3L-bus is 1.0 MHz with 20 MHz CPU of the microcontroller. The baud rate generator for the SCL line can be determined by the following formula: BSSC = fCPU 2 * ( + 1) SSCBR = ( fCPU 2 * BaudrateSSC represents the content of the reload register. For example, SSCBR = (20M/(2*1.0M)) -1 = 9. In order to achieve 1.0 MHz of SCL clock frequency, SSCBR must be assigned as 09H which is based on 20 MHz CPU clock of 16X microcontroller. The HS-SSC uses 3 I/O lines for communication; SCLK (P3.13 & DP3.13 = 1) serves as the clock line, MRST (P3.8 = X, DP3.8 = 0) serves as the serial data input line (master receive/slave transmit), and MTSR (P3.9 & DP3.9 = 1) serves as the serial data output(master transmit/slave receive). The P3.8 and P3.9 pins are connected together as the SDA line for half duplex operation. The operating mode of the SSC is controlled by the control register SSCCON. It has a common configuration as the 8 bit data with LSB first, in master mode, high for idle clock line, and high-to-low transition for leading clock edge. When the M3L- bus is in transmission mode, configured the SSC to shift transmit data on the leading clock edge. When the M3L-bus is in reception mode, it is configured to latch receive data on leading clock edge, This software module will check the clock line before a byte of data is sent or received. It also checks for WAIT condition before generating a STOP condition. A time delay of minimum tDWAIT = 750 ns is needed before checking for WAIT condition after a byte of data is sent /received or before a next byte of data is sent/received. A time delay is needed to allow enough time for the slave device to pull down the SCL line if the execution time of C16X microcontroller is shorter than 750 ns.
) -1
Semiconductor Group
8 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
The M3L_HSSC.C software module is divided into 5 software subroutines which can be accessed by the main or external program. Those 5 software subroutines are used to construct the data transfer format of the M3L-bus which consists of two types; writing data to slave, and reading data from slave. Those 5 software subroutines are M3lInit, M3lStart, M3lMasterWrite, M3lMasterRead, and M3lStop. The two types of data transfer format are written in the M3L_TEST.C. The M3L_TEST.C is a simple test program which just to verify the M3L_HSSC.C software module. This test program is to transmit 6 bytes of data to MegaText IC from the array location of the microcontroller. The 6 bytes of data will be stored in the R8 to R13 of the MegaText IC. Next, the microcontroller will read back the contents of the 6 bytes from R8 to R13 of the MegaText IC and then store it into another array location of the microcontroller.
Semiconductor Group
9 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
3.2
Description of Module Subroutines
M3L-BUS Software Module
Source file: Header file: M3L_HSSC.C
Description This module is a standard M3L-bus single master protocol by using hardware peripheral of High-Speed Synchronous Serial Channel for C16X microcontroller.
Module Subroutines 1. void CheckClockLine(); 2. void M3lInit(); 3. unsigned char M3lStart(); 4. void M3lMasterWrite(unsigned char input_byte); 5. unsigned char M3lMasterRead(); 6. void M3lStop();
void CheckClockLine() Read the SCL line for WAIT condition. It will wait until the line has been released from slave device. A time delay of minimum 750 ns is implemented before checking for WAIT condition to allow more time for slave device to pull down the SCL line. Parameter None Description
Semiconductor Group
10 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
void M3lInit() Initialize the port and serial communication. P3.7 - I2CEN, P3.13 - SCLK, P3.8 & P3.9 SDA. Configure the synchronous channel to the baud rate of 1.0 MBaud. Pull-up resistors are required for SCL and SDA lines. Parameter None Description
unsigned char M3lStart() Generate a start condition on M3L bus. Before that, check the data line for any bus faulty like no pull-up resistor on SDA or pull-down to low by the slave device. The time-out for data line is approximately 10 ms before the start of M3L protocol. Parameter None Description
Return The return value is "0" if the clock and data lines have no problem. Otherwise, the return value will be "1".
void M3lMasterWrite(unsigned char input_byte) Output one byte of data to the slave device. Before that, check for any WAIT condition. Parameter unsigned char input_byte Description one byte of data to be sent to slave.
Semiconductor Group
11 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
unsigned char M3lMasterRead() Read one byte of data from the slave device. Before that, check for any WAIT condition. Parameter None Description
Return Master device will receive one byte of data from the slave device.
void M3lStop() Check for any WAIT condition before generating a STOP condition on the M3L-bus. Parameter None Description
Semiconductor Group
12 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
M3L-BUS Application Software
Source file: Header file: M3L_TEST.C M3L.H
Description This main program is to transmit 6 bytes of data to MegaText (SDA 5273) from the "raw_data" array. The 6 bytes of data will be stored in the R8 to R13 of MegaText IC. The device address of SDA 5273 is MSB (R/W)1000100 LSB. In M3L bus mode, the LSB of a byte is transmitted first. The sub-address of R8 is 00001000B. Next, the microcontroller will read back the contents of the 6 bytes from R8 to R13 and store it in the "stored_data" array.
Software subroutines 1. unsigned char WriteMegatext(unsigned char sub_addr,unsigned char *buffer,unsigned char num_byte) 2. unsigned char ReadMegatext(unsigned char sub_addr,unsigned char *buffer,unsigned char num_byte)
unsigned char WriteMegatext(unsigned char sub_addr,unsigned char *buffer,unsigned char num_byte) Write number of data bytes to MegaText. The flow of this subroutine is derived from the data format of writing to the MegaText as in the figure #1. If there is a bus faulty, the data will not be written. Parameter unsigned char sub_addr unsigned char *buffer unsigned char num_byte Description specifies the sub-address point to the addressed location number of bytes to be written
Return The return value is "0" if the clock and data lines have no problem. Otherwise, the return value will be "1".
Semiconductor Group
13 of 14
AP1627 1.97
Software module of M3L-bus by using HS-SSC for C16X uC family
unsigned char ReadMegatext(unsigned char sub_addr,unsigned char *buffer,unsigned char num_byte) Read number of bytes from MegaText. The flow of this subroutine is derived from the data format of reading from the MegaText as in the figure #2. If there is a bus faulty, the data will not be read. Parameter unsigned char sub_addr unsigned char *buffer unsigned char num_byte Description specifies the sub-address point to the addressed location number of bytes to be read
Return The return value is "0" if the clock and data lines have no problem. Otherwise, the return value will be "1". 3.3 Compilation of Software
The compilation of this software is using the KEIL C166 compiler. First of all, under the PROJECT, clicks on the "New Project", then key in the name of this project and add files to the project which are the M3L_HSSC.C and M3L_TEST.C. Then, save the project. After-that, go to the OPTIONS and click on the "C166 Compiler..." . Lastly, select the option under OBJECT and cross the box under "Enable 80C167 instructions". This option will allow you to use the C16X derivatives. Now the project is really to compile and link all the object files. The compiling and linking of the project can be done by clicking the icon "BUILD ALL". The AP162701.EXE is a compressed file contains M3L.H, M3L_HSSC.C, and M3L_TEST.C. All these files are necessary to complete the compilation of the software program.
Semiconductor Group
14 of 14
AP1627 1.97


▲Up To Search▲   

 
Price & Availability of AP1627

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X